package com.ruoyi.controller;

import com.ruoyi.domain.common.ResponseResult;
import com.ruoyi.domain.entity.Stock;
import com.ruoyi.domain.vo.SearchVo;
import com.ruoyi.domain.vo.StockDetailVo;
import com.ruoyi.service.StockService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

@RestController
@RequestMapping("/stock")
@Tag(name = "股票接口")
public class StockController {
    @Resource
    private StockService stockService;

    @GetMapping("/stockInfo")
    @Operation(summary = "获取股票基本信息")
    public ResponseResult<Stock> getStockDetail(Integer stockId) {
        Stock stock = stockService.getStockDetail(stockId);
        return ResponseResult.success(stock);
    }

    @GetMapping("/getStockDesc")
    @Operation(summary = "获取股票简介")
    public ResponseResult<String> getStockDescription(Integer stockId) {
        String description = stockService.getStockDescription(stockId);
        return ResponseResult.success(description,"");
    }

    @GetMapping("/getSearchStock")
    @Operation(summary = "获取搜索股票列表")
    public ResponseResult<List<Stock>> getSearchStock(@RequestParam String keyword) {
        // 调用服务层方法获取搜索到的股票列表
        List<Stock> stockList = stockService.searchStocks(keyword);
        // 返回成功响应结果
        return ResponseResult.success(stockList);
    }

}